package com.fanrui.code.thread;

import com.fanrui.code.threadgroup.GroupingAlgorithm;

public class ModuloGroupingAlgorithm implements GroupingAlgorithm<Long> {

	private int groupSize;

	public ModuloGroupingAlgorithm(int groupSize) {
		super();
		this.groupSize = groupSize;
	}
	
	@Override
	public int getGroupSize() {
		return this.groupSize;
	}

	@Override
	public int getGroup(Long entityId) {
		return (int) (entityId % this.groupSize);
	}

}
